package net.weitalk.newfeatures;

/**
 * Text Blocks is released in JDK15.
 */
public class TextBlocks {
    public static void main(String[] args) {
        String stringBlock =
                "<!DOCTYPE html>\n" +
                        "<html>\n" +
                        "    <body>\n" +
                        "        <h1>\"Hello World!\"</h1>\n" +
                        "    </body>\n" +
                        "</html>\n";

        String textBlock = """
                <!DOCTYPE html>
                <html>
                    <body>
                        <h1>"Hello World!"</h1>
                    </body>
                </html>
                """;

        System.out.println(
                "Does the text block equal to the regular string? " +
                        stringBlock.equals(textBlock));
        //文字块是在编译期处理的，并且在编译期被转换成了常量字符串，然后就被当作常规的字符串了。
        //所以，如果文字块代表的内容，和传统字符串代表的内容一样，那么这两个常量字符串变量就指向同一内存地址，代表同一个对象。
        System.out.println(
                "Does the text block refer to the regular string? " +
                        (stringBlock == textBlock));
    }
}